package com.demo.controller;

import com.demo.dto.Result;
import com.demo.entity.Shop;
import com.demo.service.IShopService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/shop")
public class ShopController {

    @Resource
    private IShopService shopService;

    /**
     * 根据id查询商户信息
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public Result queryShopById(@PathVariable("id") Long id){
        return Result.ok(shopService.queryById(id));
    }

    /**
     * 更新商铺信息
     * @param shop
     * @return
     */
    @PutMapping
    public Result updateShop(@RequestBody Shop shop){
        //写入数据库
        return  shopService.update(shop);
    }
}